<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">111</div>
  <button onclick="click1()">add</button>
  <button onclick="click2()">delete</button>
  <script>
    const app = document.getElementById('app')
    let obj = {
        name: 'zs',
        age: 12
      },
      obj2 = {
        name: 'wangwu',
        sex: 1
      },
      flag = 0


    let arr = [],
      i = 0;
    for (arr[i++] in obj) {}

    function merge(a, b) {

      if (flag > 0) return
      with(obj) {
        name = 'ls'
        age = '18'
      }
      for (const key in a) {
        if (key in b) continue
        b[key] = a[key]
      }
      flag++
      app.innerHTML = obj.name + ' ' + obj.age + '<br>' + JSON.stringify(obj2)
    }

    function deleteEL(a,b){
      for (const key in b) {
        if(key in a) continue
        delete b[key]
      }
      app.innerHTML = obj.name + ' ' + obj.age + '<br>' + JSON.stringify(obj2)
    }

    function click1() {
      merge(obj, obj2)
    }

    function click2(){
      deleteEL(obj,obj2)
    }

    app.innerHTML = obj.name + ' ' + obj.age + '<br>' + JSON.stringify(obj2)
  </script>
</body>

</html>